import Vue from "vue";
import VueRouter from "vue-router";
import Login from "../views/Login.vue";
import Home from "../views/Home.vue";
import Welcome from "../views/Welcome.vue";
import HpcTotalResource from "../views/product/hpc/HpcTotalResourcr.vue";
import UsageResource from "../views/product/hpc/UsageResource.vue";
import TotalContract from "../views/product/hpc/TotalContract.vue";
import TotalResource from "../views/product/idc/TotalResource.vue";
import RemainResource from "../views/product/idc/RemainResource.vue";
import TotalHostResource from "../views/product/idc/TotalHostResource.vue";
import UsageHostResource from "../views/product/idc/UsageHostResource.vue";

Vue.use(VueRouter);

const routes = [
  {
    path: "/",
    redirect: "/login"
  },
  {
    path: "/login",
    component: Login
  },
  {
    path: "/home",
    component: Home,
    redirect: "/welcome",
    children: [
      {
        path: "/welcome",
        component: Welcome
      },
      {
        path: "/hpctotalResource",
        component: HpcTotalResource
      },
      ,
      {
        path: "/usageResource",
        component: UsageResource
      },
      {
        path: "/totalContract",
        component: TotalContract
      },
      {
        path: "/totalResource",
        component: TotalResource
      },
      {
        path: "/remainResource",
        component: RemainResource
      },
      {
        path: "/totalHostResource",
        component: TotalHostResource
      },
      {
        path: "/usageHostResource",
        component: UsageHostResource
      }
    ]
  }
];

const router = new VueRouter({
  routes
});

// router.beforeEach((to, from, next) => {
//   if (to.path === "/login") return next();
//   const tokenStr = window.sessionStorage.getItem("token");
//   if (!tokenStr) return next("/login");
//   next();
// });

export default router;
